export interface ReqUserAddParams {
  pwd: string
  passwordConfirm: string
  phone: string
  account: string
  nickName: string
  weChartAccount: string
  email: string
  userType: string
  saleUserId: string
  consumptionAmountLimit: 0
  cashbackAmountLimit: 0
  wxQrCode: string
  balance: 0
  status: boolean
  descption?: string
}

// 新增
export function addApi(params: ReqUserAddParams) {
  return usePost<any>('/user/add', params, {
    // 设置为false的时候不会携带token
    token: true,
    // 开发模式下使用自定义的接口
    customDev: true,
    // 是否开启全局请求loading
    loading: true,
  })
}

// 删除
export async function delApi(ids: string) {
  return useDelete(`/user/delete/${ids}`)
}
// 修改
export interface ReqUserUpdateParams {
  pwd: string
  passwordConfirm: string
  phone: string
  nickName: string
  weChartAccount: string
  email: string
  userType: string
  saleUserId: string
  consumptionAmountLimit: 0
  cashbackAmountLimit: 0
  wxQrCode: string
  balance: 0
  descption: string
  status: boolean
}
export function updateApi(params: ReqUserUpdateParams) {
  return usePut('/user/update', params, {
    // 设置为false的时候不会携带token
    token: true,
    // 开发模式下使用自定义的接口
    customDev: true,
    // 是否开启全局请求loading
    loading: true,
  })
}

// 查询
export interface ReqUserQueryParams {
  phone: 'mobile'
  account: string
  nickName: string
  weChartAccount: string
  email: string
  userType: string
  saleUserId: string
  status?: boolean
  pageNo?: number
  pageSize?: number
}

export interface RepPage {
  pageNo?: number
  pageSize?: number
  totalCount?: number
  totalPage?: number
  data?: RepUserInfo[]
}

export interface RepUserInfo {
  id: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  phone: string
  account: string
  nickName: string
  weChartAccount: string
  email: string
  userType: string
  saleUserId: string
  consumptionAmountLimit: 0
  cashbackAmountLimit: 0
  wxQrCode: string
  salesLink: string
  balance: 0
  lastLoginTime: string
  lastLoginIp: string
  loginTotalCount: 0
  status: boolean
  descption: string
}
export function queryApi(params: ReqUserQueryParams) {
  return usePost<RepPage>('/user/pages', params, {
    // 设置为false的时候不会携带token
    token: true,
    // 开发模式下使用自定义的接口
    customDev: true,
    // 是否开启全局请求loading
    loading: true,
  })
}
